﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ERP.Business.DataTypes.Users;
using System.Reflection;

namespace ERP.UI.SystemAdministrator
{
    /// <summary>
    /// Represents the application's global variables
    /// </summary>
    public abstract class ApplicationVariables
    {
        private static User m_CurrentUser = null;
        /// <summary>
        /// Get/Set logged-in user
        /// </summary>
        public static User CurrentUser
        {
            get
            {
                return m_CurrentUser;
            }
            set
            {
                m_CurrentUser = value;
            }
        }

        /// <summary>
        /// Get the Assebly's GUID value which represents the Application ID
        /// </summary>
        public static string ApplicationID
        {
            get
            {
                object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(System.Runtime.InteropServices.GuidAttribute), false);
                if (attributes.Length > 0)
                {
                    System.Runtime.InteropServices.GuidAttribute titleAttribute = (System.Runtime.InteropServices.GuidAttribute)attributes[0];
                    if (titleAttribute.Value != "")
                    {
                        return titleAttribute.Value;
                    }
                }
                return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
            }
        }
    }
}
